#!/bin/sh

p_w_d=$PWD
len_of_list=$#
echo $* > ./this_event.file
this_hash=`md5sum ./this_event.file`
this_hash=${this_hash%% *}
/bin/rm this_event.file

echo 0 > ./aleardy.${this_hash}.file


change_aleardy(){
    echo $1 > ./aleardy.${this_hash}.file

    if test $(cat ./aleardy.${this_hash}.file) -eq $len_of_list
    then
        /bin/rm ./aleardy.${this_hash}.file
    fi
}
gclll(){
    finished_flag=0
    git clone $1 && export aleardy=`expr $(cat ./aleardy.${this_hash}.file) + 1 ` && echo "第${aleardy}个包已克隆, 还剩`expr $len_of_list - $aleardy`个" && finished_flag=1

    if test $finished_flag -eq 1
    then
        change_aleardy $aleardy
    elif test $2 -eq 10
    then
        echo "放弃clone $1"
    else
        gclll $1 $[$2+1]
    fi
}



for val in $@ ; do
    gclll $val 0 &
done
